/********************************************************************************
 *      Copyright:  (C) 2021 iot
 *                  All rights reserved.
 *
 *       Filename:  conf.h
 *    Description:  This head file 
 *
 *        Version:  1.0.0
 *         Author:  mk
 *                 
 ********************************************************************************/
#ifndef  _CONF_H_
#define _CONF_H_

#include "../hal/hal.h"

enum
{
    Qos0, 
    Qos1, 
    Qos2, 
};

typedef struct log_ctx_s
{
    /*  logger settings */
    char          logfile[128]; /*  logger record file */
    int           loglevel;     /*  logger level  */
    int           logsize;      /*  logger file maxsize, oversize will rollback */
} log_ctx_t;



typedef struct mqtt_ctx_s
{
    char          id[64];       /*   production ID */

    /*  Broker settings  */
    char          host[128];  /*  MQTT broker server name  */
    int           port;       /*  MQTT broker listen port  */
    char          uid[64];    /*  username */
    char          pwd[64];    /*  password */
    int           keepalive;  /*  MQTT broker send PING message to subsciber/publisher keepalive timeout<seconds> */

    /*  Subscriber settings */
    char          subTopic_ack[256]; /*  Subscriber topic */
    char          subTopic_led[256]; /*  Subscriber topic */
    int           subQos;        /*  Subscriber Qos  */

    /*  Publish  setting */
    int           interval;
    char          pubTopic_reg[256];
    char          pubTopic_temp[256];
    int           pubQos;
}mqtt_ctx_t;


typedef struct all_ctx_s
{
    log_ctx_t     log_ctx;
    light_ctx_t   light_ctx;
    mqtt_ctx_t    mqtt_ctx;

}all_ctx_t;

extern int parser_conf(const char *conf_file, all_ctx_t *ctx, int debug);


#endif

